#ifndef JPROJECTMODEL_H
#define JPROJECTMODEL_H

#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>

class JProjectItem;

class JProjectModel : public QAbstractItemModel
{
    Q_OBJECT

public:
    JProjectModel(const QStringList &headers, QObject *parent = 0);
    ~JProjectModel();

    QVariant data(const QModelIndex &index, int role) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;

    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
    QModelIndex parent(const QModelIndex &index) const;

    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;

    Qt::ItemFlags flags(const QModelIndex &index) const;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole);

    bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
    bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
    bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
    bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());

	void setCurrentProject(const QString &name);

private:
    void setupModelData(const QStringList &lines, JProjectItem *parent);
    JProjectItem *getItem(const QModelIndex &index) const;

    JProjectItem *m_rootItem;
};

#endif
